<?php

if($this->type=="list"){
   foreach ($this->row as $admin) :
       ?>
    <li onClick="fill('<?php echo $this->escape($admin['admin_id']).'\',\''.
            $this->page;?>');">
    <?php echo $this->escape($admin['name']);?></li>
<?php    endforeach;
          
}else if(($this->type=="display" && $this->page=="list")){
?>
    <div class="tabledata" id="tabledata">
    <table class="tablesorter">
    <tr class="top">

            <td colspan="3" style="text-align:left">
<div class="add">
<a class="abutton" href="<?php echo $this->url(array("controller"=>"admin","action"=>"add")); ?>">
<img src="<?php echo $this->baseUrl(); ?>/images/icons/add.png" />Tambah</a>
</div>
            </td>
            <td colspan="5" style="text-align:right;">
                <img style="margin-bottom:-3px;margin-top:4px;" src="<?php echo $this->baseUrl(); ?>/images/icons/pencil.png" /> = edit Admin &nbsp;&nbsp;&nbsp;
                <img style="margin-bottom:-3px;margin-top:4px;" src="<?php echo $this->baseUrl(); ?>/images/icons/cross.png" /> = hapus Admin
            </td>
 </tr>
<tr class="head">
    <td>
    <a class="sort"  href="<?=$this->url(array('controller'=>'admin',
            'action'=>'list', 'order'=>'admin_id','method'=>$this->method))?>">
    ID
    </a></td>
    <td>
     <a class="sort"  href="<?=$this->url(array('controller'=>'admin',
            'action'=>'list', 'order'=>'name','method'=>$this->method))?>">
    Name</a></td>
    <td>
    <a class="sort" href="<?=$this->url(array('controller'=>'admin',
        'action'=>'list', 'order'=>'username','method'=>$this->method))?>">
        Username</a></td>
    <td>
 <a class="sort" href="<?=$this->url(array('controller'=>'admin',
     'action'=>'list', 'order'=>'role_id','method'=>$this->method))?>">
     Jabatan</a></td>
    <td>
   <a class="sort" href="<?=$this->url(array('controller'=>'admin',
        'action'=>'list', 'order'=>'email','method'=>$this->method))?>">
       Email</a></td>
    <td>
     <a class="sort" href="<?=$this->url(array('controller'=>'admin',
        'action'=>'list', 'order'=>'phone','method'=>$this->method))?>">
    Nomor Telepon</a></td>
    <td>
    Keterangan</td>
    <td>&nbsp;</td>
</tr>
<span id="table-content">

<?php foreach($this->admins as $admin) : ?>
<tr style="background-color: <?= $this->cycle(array("#ccffcc","#99ff99"))->next(); ?>;">

    <td>  <a href="<?php echo $this->url(array('controller'=>'admin',
            'action'=>'details', 'id'=>$admin['admin_id']));?>">
        <?php echo $this->escape($admin['admin_id']);?></a>
    <td><?php echo $this->escape($admin['name']);?></td>
    <td><?php echo $this->escape($admin['username']);?></td>
    <td><?php echo $this->role->getRoleName($this->escape($admin['role_id']));?></td>
    <td><?php echo $this->escape($admin['email']);?></td>
    <td><?php echo $this->escape($admin['phone']);?></td>
    <td><?php echo $this->escape($admin['details']);?></td>
    <td>
        <a href="<?php echo $this->url(array('controller'=>'admin',
            'action'=>'edit', 'id'=>$admin['admin_id']));?>">
            <img src="<?php echo $this->baseUrl(); ?>/images/icons/pencil.png" alt="edit"/></a>
        <a href="javascript:deleting('<?php echo $this->url(array('controller'=>'admin',
            'action'=>'remove', 'id'=>$admin['admin_id']));?>')">
            <img src="<?php echo $this->baseUrl(); ?>/images/icons/cross.png" alt="delete"></a>
    </td>
</tr>
<?php endforeach; ?>
<tr>
    <td colspan="7">
           <?= $this->back?>
            <?= $this->current?>/<?=$this->totalPages?>
          <?=$this->next?>
    </td>
</tr>
</span>
</table>
    </div>
<?php
}else if(($this->type=="display" || $this->type=="sorting") && $this->page=="peran"){?>
<table>
<tr class="head">
    <td>
        <a class="sort" href="<?=$this->url(array('controller'=>'admin',
        'action'=>'changerole', 'order'=>'admin_id','method'=>$this->method))?>">
    ID
    </a></td>
    <td>
        <a class="sort" href="<?=$this->url(array('controller'=>'admin',
        'action'=>'changerole', 'order'=>'name','method'=>$this->method))?>">
    Name</a></td>
    <td>
     <a class="sort" href="<?=$this->url(array('controller'=>'admin',
         'action'=>'changerole', 'order'=>'username','method'=>$this->method))?>">
         Username</a></td>
    <td>
    <a class="sort" href="<?=$this->url(array('controller'=>'admin',
        'action'=>'changerole', 'order'=>'role_id','method'=>$this->method))?>">
        Jabatan</a></td>
</tr>
<?php foreach($this->admins as $admin) : ?>
<tr style="background-color: <?= $this->cycle(array("#ccffcc","#99ff99"))->next(); ?>;">
    <td>
        <?php echo $this->escape($admin['admin_id']);?></td>
    <td><?php echo $this->escape($admin['name']);?></td>
    <td><?php echo $this->escape($admin['username']);?></td>
    <?php

                //Create role DB
                $this->form->role->setLabel("")
                        ->setAttrib("onChange","confirmRole('".$this->url(array('controller'=>'admin',
                           'action'=>'search', 'adminId'=>$admin['admin_id'],'type'=>'change'))."',this.value)")
                        ->setValue($admin['role_id'],$this->role->getRoleName($admin['role_id']));

    ?>
    <td><?php echo $this->form;?></td>
</tr>
<?php endforeach; ?>

    <tr>
    <td colspan="7">
           <?= $this->back?>
           <?= $this->current?>/<?=$this->totalPages?>
          <?=$this->next?>
    </td>
</tr>
<tr>
    <td>
                  <a class="listed" href="<?php echo $this->url(array('controller'=>'admin',
            'action'=>'list'));?>">
            <img class="listed" src="<?php echo $this->baseUrl(); ?>/images/icons/arrow_left.png" alt="Back"/>
                    </a>
                </td><td>

    </td>
    </tr>
</table>
<?php  
}else if($this->type=="date"){
    ?>
<?php foreach($this->log as $logs) : ?>
<p><?php echo "[".$this->escape($logs['time'])."] ".
               $this->escape($logs['username'])." ".$this->escape($logs['role'])
               ." ".$this->escape($logs['action']).""; ?></p>
<?php endforeach; ?>
    <?php
}
?>